//
// Created by user on 2022/3/4.
//
#include <vector>
#include <algorithm>
using namespace std;

//滑动窗口
int minSubArrayLen(int target, vector<int>& nums) {
    int ans = INT_MAX;;

    int left = 0;
    int right = 0;
    int windowSum = 0;
    while (right<nums.size()){
        windowSum+=nums[right];
        while (windowSum>=target){
            ans = min(right-left+1, ans);
            windowSum-=nums[left];
            left++;
        }
        right++;
    }
    return ans==INT_MAX?0:ans;
}

//前缀和
int minSubArrayLen1(int target, vector<int>& nums) {

}